package com.itsxb.controller.app;

import cn.dev33.satoken.annotation.SaIgnore;
import com.itsxb.pojo.domain.CustomerCar;
import com.itsxb.pojo.dto.CustomerDto;
import com.itsxb.pojo.vo.AddCarVo;
import com.itsxb.result.R;
import com.itsxb.service.ICustomerCarService;
import com.itsxb.service.ICustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/app/customer")
public class AppCustomerController {
    @Autowired
    private ICustomerService customerService;
    @Autowired
    private ICustomerCarService customerCarService;
    @PostMapping("/wechatRegistory")
    @SaIgnore
    public R customerLogin(@RequestBody @Valid CustomerDto customerDto){
        customerService.wechatRegistory(customerDto);
        return R.success();
    }
    @PostMapping("/loadCarList")
    public R loadCarList(){
        List<CustomerCar> customerCars = customerCarService.loadCarList();
        return R.success(customerCars);
    }

    @PostMapping("/addCar")
    public R addCar(@RequestBody @Valid AddCarVo AddCarVo){
        customerCarService.addCar(AddCarVo);
        return R.success();
    }
}
